/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package JDBCUtil;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author Administrator
 */
public class MyConn {
    static Connection conn;
    static String str="jdbc:sqlserver://localhost:1433;database=Matrimony;user=sa;password=1234567";
    
    public static Connection getConnection() throws SQLException, ClassNotFoundException{
        if(conn !=null && !conn.isClosed()){
            return conn;
        }
        
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        conn= DriverManager.getConnection(str);
        return conn;
    }
    
//    public static void main(String[] args) throws SQLException, ClassNotFoundException {
//        //getConnection();
//        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
//                Date date = new Date();
//        String getdate = dateFormat.format(date);
//        System.out.println(date);
//    }
}
